package object1;

public class Date {
    private int year = 1900;   //年
    private int month = 1;  //月
    private int day = 1;    //日
    //误餐构造方法
    public Date(){
//        year = 1900;
//        month = 1;
//        day = 1;
//        printDate();
        this(1970, 1, 1);
    }
    //有参构造方法
    public Date(int year, int month, int day){
        this.year = year;
        this.month = month;
        this.day = day;
    }
    //设置日期
    public void setDate(int year, int month, int day){
        this.year = year;
        this.month = month;
        this.day = day;
    }
    //打印日期
    public void printDate(){
        System.out.println(year + "-" + month + "-" + day);
    }

    public static void main(String[] args){
        Date date1 = new Date();
        Date date2 = new Date();
        Date date3 = new Date();
        date1.year = 2022;

        date1.printDate();
        date2.printDate();
        date3.printDate();

        date1.setDate(2025, 3, 8);
        date2.setDate(2025, 4, 10);
        date3.setDate(2025, 5, 15);

        date1.printDate();
        date2.printDate();
        date3.printDate();
    }
}
